$(function(){
	getUserDetail();
});
function getUserDetail(){
	var contentUrl=$("#contextPath").attr("value");
	$.ajax({
		type : "POST",
		url : "getUserMenus.html",
		success : function(data) {
			var tar = $("#side-menu");
			tar.empty();
			var menuStr="";
			for(var i=0;i<data.length;i++){
				menuStr+="<li><a href='#TopMenu_'"+data[i].menuId+"' id='TopMenu_"+data[i].menuId+"'><i class='fa fa-dashboard fa-fw'></i> "+data[i].menuName+"<span class='fa arrow'></span></a> ";
				if(data[i].subMenus!=null&&data[i].subMenus.length!=0){
					var subMenus=data[i].subMenus;
					menuStr+=" <ul class='nav nav-second-level'>";
					for(var j=0;j<subMenus.length;j++){
						menuStr+="<li><a href='"+contentUrl+subMenus[j].menuUrl+"'>"+subMenus[j].menuName+"</a></li>";
					}
					menuStr+="</ul>";
				}
				menuStr+="</li>";
			}
			tar.append(menuStr);
			
			tar.find('li.active').has('ul').children('ul').addClass('collapse in');
			tar.find('li').not('.active').has('ul').children('ul').addClass('collapse');
			tar.find('li').has('ul').children('a').on('click', function (e) {
	               e.preventDefault();
	               $(this).parent('li').toggleClass('active').children('ul').collapse('toggle');
	               if ($toggle) {
	                    $(this).parent('li').siblings().removeClass('active').children('ul.in').collapse('hide');
	               }
	            });
		},
		error : function(XMLHttpRequest, textStatus,errorThrown) {
		}
	});
}